<template>
    <div>
        <el-row style="margin: 10px 20px 10px 10px;">
            <el-switch v-model="switchvalue" active-text="按年、月查询" inactive-text="按年查询" @change="change_switchvalue"></el-switch>
            <el-input v-model="rowdata.year" placeholder="请输入内容" :disabled="true"  style="margin-left: 30px;width: 120px;">
                <template slot="append">年</template>
            </el-input>
            <el-select v-model="rowdata.month" placeholder="请选择" v-if="switchvalue==true" style="margin-left: 30px;">
                <el-option v-for="item in 12" :key="item" :label="item+'月'" :value="item"></el-option>
            </el-select>
        </el-row>
        <el-table style="width:92%" :data="dfsjrecoderTrue"  border  :empty-text="showemptytext" >
            <el-table-column  width="65" label="标识" :show-overflow-tooltip='true' align="center">
                <template slot-scope="scope">
                    <img class="default-image" :src="$store.state.images.wujiaoxing" style="width：45px;height:45px;"> 
                </template> 
            </el-table-column>
            <el-table-column type="index" width="120" label="序号"  :index="indexbf" :show-overflow-tooltip='true'  align="center">
            </el-table-column>
            <el-table-column prop="year" width="80" label="年份"   :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="month" width="60" label="月份"   :show-overflow-tooltip='true'  align="center" v-if="switchvalue==true"></el-table-column>
            <el-table-column prop="dwname" width="305" label="党委名称" :show-overflow-tooltip='true'  align="center" v-if="ZongShow==true"></el-table-column>
            <el-table-column prop="dzbname" width="305" label="党支部名称" :show-overflow-tooltip='true'  align="center" v-if="DwShow==true"></el-table-column>
            <el-table-column prop="truename" width="125" label="缴纳人" :show-overflow-tooltip='true'  align="center"  v-if="DzbShow==true"></el-table-column>
            <el-table-column prop="needJiao" width="85" label="应交数" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="trueJiao" width="85" label="实交数" :show-overflow-tooltip='true'  align="center"></el-table-column>
            <el-table-column prop="time" width="125" label="缴纳时间" :show-overflow-tooltip='true'  align="center" v-if="switchvalue==true &&DzbShow==true"></el-table-column>
            <template v-if="(DwShow==true||ZongShow==true)">
                <el-table-column prop="zz" type="text" label="在职" width="85" align="center" ></el-table-column>
                <el-table-column prop="tx" width="85" label="退休" :show-overflow-tooltip='true' align="center"></el-table-column>
            </template>
            <template v-if="(DwShow==true||ZongShow==true)&&showallFileds">
                <el-table-column prop="trueJiao2" type="text" label="上交数额" width="180" align="center" ></el-table-column>
                <el-table-column prop="uploadtime" width="125" label="上交时间" :show-overflow-tooltip='true' align="center"></el-table-column>
                <el-table-column prop="truesrc" width="125" label="上交清单文件" :show-overflow-tooltip='true' align="center">
                    <template slot-scope="scope" >
                        <template v-if="scope.row.truesrc==''"><a target="_blank" >无</a></template>
                        <template v-if="scope.row.truesrc!=''"><a target="_blank" :href="scope.row.truesrc">点击查看</a></template>
                    </template> 
                </el-table-column>
                <el-table-column prop="stroe" width="165" label="清单文件存放" :show-overflow-tooltip='true' align="center"></el-table-column>
            </template>
            <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                    <el-button  size="mini"    @click="serchdf">查询</el-button>
                    <el-button  size="mini"  @click="addfile" v-show="DzbShow">新增</el-button>
                </template>
                <template slot-scope="scope">
                    <el-dropdown trigger="click" @command="handleCommand" v-if="(DwShow==true||ZongShow==true)&&(switchvalue==true)">
                        <span class="el-dropdown-link">操作<i class="el-icon-caret-bottom el-icon--right"></i></span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item class="clearfix" :command="{data:scope.row,typed:'edit'}">编辑</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
        <pagination @changed="showdfsjRecoderstrue" :recoder="dfsjrecoder"> </pagination>
        <dfeiadd ref='dfeiadd' v-on:editResult="serchdf"></dfeiadd>
    </div>
</template>
<script>
import {mapActions} from 'vuex';
    export default {
        data() {
            return { 
                dialogVisible: false, 
                switchvalue:false,
                rowdata:{
                    year:'2018',
                    month:1,
                },
                switchvalue:false,
                showallFileds:false,
                
                

                dfsjrecoder:[],
                dfsjrecoderTrue:[],
                offset:0,


                DzbShow:false,//当进入的是党支部级别是 显示的是当前党支部各党员缴纳的党费
                DwShow:false,//当进入院级别时 看到的时 各个党支部的缴纳情况 以及缴纳的单据
                ZongShow:false,//当进入局级别时 看到的时 各个院部的缴纳情况 以及缴纳的单据



                showpersons:[],
                rules: {
                    yearmonth: [{ required: true, message: '不能为空', trigger: 'blur' }],
                    year: [{ required: true, message: '不能为空', trigger: 'blur' }],
                },


                default_emptytext:"请点击右侧查询记录",
                showemptytext:'',
            };
            
        },
        mounted() {
            if(this.GetUser()==false){
                this.$router.push("/");
            }
            this.GetActiveDwId_DzbId();
            if(this.$store.state.Dw_DzbID.dwid==-1){
                this.ZongShow=true;this.DzbShow=false;this.DwShow=false;

            }
            else if(this.$store.state.Dw_DzbID.dzbid==-1){
                this.ZongShow=false;this.DzbShow=false;this.DwShow=true;
            }
            else{
                this.ZongShow=false;this.DzbShow=true;this.DwShow=false;
            }
        },
        watch: {
        },
        components: {
            dfeiadd: function(resolve) {require(["./dfeiadd.vue"], resolve);},
            // dfeieditdw: function(resolve) {require(["./dfeieditdw.vue"], resolve);},
        },
        methods: {
            ...mapActions(['GetUser','GetZbById','GetActiveDwId_DzbId']),
            change_switchvalue(){
                this.dfsjrecoder=[];
            },
            showdfsjRecoderstrue(showrecoders,offset){
                this.dfsjrecoderTrue=showrecoders;
                this.offset=offset;
            },
            indexbf(index){return index+this.offset+1;},
            serchdf()
            {
                this.dfsjrecoder=[];
                let _this=this;
                let data={
                    dwid:this.$store.state.Dw_DzbID.dwid,
                    dzbid:this.$store.state.Dw_DzbID.dzbid,
                    year:this.rowdata.year,
                }
                if(this.switchvalue==false){
                    data.month=-1
                }
                else{
                    data.month=this.rowdata.month
                }
                let postdata={
                    type:"serchdangfei",
                    split:JSON.stringify(data)
                }

                _this.$Common.AjaxPost(postdata,true)
                .then(function(e){
                    if(e.dfeis.length==0){
                        _this.showemptytext='没有找到记录';
                        setTimeout(() => {
                            _this.showemptytext=_this.default_emptytext;
                        }, 1000);
                    }
                    else{
                        _this.dfsjrecoder=e.dfeis; 
                    }
                });


                // let dfeis=AjaxPostSyncdata.Data.dfeis;
                //     for (let index = 0; index < dfeis.length; index++) {
                //         const element = dfeis[index];
                //         let postdata_element={
                //             type:"selectdfeitime",
                //             split:JSON.stringify({
                //                 dwid:element.dwid,
                //                 dzbid:element.dzbid,
                //                 year:element.year,
                //                 month:element.month
                //             })
                //         }
                //         let AjaxPostSyncdata2=this.$Common.AjaxPostSync(postdata_element,true).Data;
                //         if(AjaxPostSyncdata2==null){
                //             element.truesrc='';
                //         }
                //         else{
                //             element.needJiao2=AjaxPostSyncdata2.needJiao;
                //             element.trueJiao2=AjaxPostSyncdata2.trueJiao;
                //             element.uploadtime=AjaxPostSyncdata2.time;
                //             element.stroe=AjaxPostSyncdata2.stroe;
                //             element.truesrc=AjaxPostSyncdata2.truesrc;
                //         }
                        
                //         this.dfsjrecoder.push(element);
                //     }
            },
            addfile()
            {
                this.$refs.dfeiadd.$data.detailsVisible = true;
                this.$refs.dfeiadd.$data.year = this.rowdata.year;
            },
            handleCommand()
            {

            },
        },


        
    }
</script>

<style scoped>

</style>